package com.yzy.mall.component

import android.content.Context
import android.graphics.Color
import com.blankj.utilcode.util.SpanUtils
import com.blankj.utilcode.util.TimeUtils
import com.yzy.baselibrary.extention.click
import com.yzy.baselibrary.extention.startActivity
import com.yzy.mall.R
import com.yzy.mall.component.comm.CommActivity
import com.yzy.mall.repository.SaveBean
import com.yzy.mall.repository.UpdateGlobal
import kotlinx.android.synthetic.main.activity_order_success.*

class OrderSuccessActivity : CommActivity() {
    companion object {
        fun startOrderSuccessActivity(context: Context, userListBean: SaveBean) {
            context.startActivity<OrderSuccessActivity>(
                "userOrderBean" to userListBean
            )
        }
    }

    override fun layoutResId(): Int = R.layout.activity_order_success

    override fun initView() {
        val saveBean = intent.getParcelableExtra<SaveBean>("userOrderBean")
        saveBean?.let {
            tvOrderTime.text=  SpanUtils().append("订单日期：").append(TimeUtils.millis2String(System.currentTimeMillis(), "yyyy-MM-dd")).create()
            tvOrderIdNumber.text=  SpanUtils().append("订单编号：").append(TimeUtils.millis2String(System.currentTimeMillis(), "yyyy-MM-dd")).create()
            tvNameType.text=  SpanUtils().append("兑换类型：").append(it.exchangeWineName?:"").create()
            tvNumber.text=  SpanUtils().append("数量：").append(it.exchangeNum?:"").create()
            tvOrderState.text=  SpanUtils().append("订单状态：").append("已成功").create()
            tvPay.text=  SpanUtils().append("支付方式：").append(it.payMethod?:"").create()
            tvAddressName.text=  SpanUtils().append("收货人：").append(it.userName?:"").create()
            val address=it.provinceName+it.cityName +it.districtName+ it.detailAddress
            tvAddress.text=  SpanUtils().append("收货地址：").append(address).create()
            tvZipCode.text=  SpanUtils().append("邮编：").append(it.zipCode?:"").create()
            tvPhone.text=  SpanUtils().append("手机：").append(it.phoneNo?:"").create()
            tvMoneyCount.text=  SpanUtils().append("商品价格：¥").append(it.commodityTotalPrice?:"").create()
            tvPreferential.text=  SpanUtils().append("优惠金额：¥").append(it.preferentialAmount?:"").create()
            tvFreight.text=  SpanUtils().append("运费：¥").append(it.commodityFreight?:"").create()
            tvMoney.text=  SpanUtils().append("总价：¥").append(it.commodityTotalPrice?:"").create()
        }
        tvSaveSubmit.click {
            finish()
        }
        tvLeft.click {
            finish()
        }

    }

    override fun initData() {
    }

    override fun onDestroy() {
        UpdateGlobal.setSend(true)
        super.onDestroy()
    }
}